/*This is the algorithm to compute the maximum cycle length for HAILSTONE sequence between
 * A and B unsigned long integers. 
 *
 * Author- Ajeet Singh
 * http://uva.onlinejudge.org
 * id- ajeet.singh82
 * Contact- ajeet.singh82@gmail.com
 *
 * 
 * Algorithm: 
 * HSS_CYCLE_LEN len, num
 * 	a. len := no. of trailing zeros // n/2
 * 	b. num >>= len 
 * 	c. key :- hash_key(num)
 * 	d. if key < chache_size && chache[key] != 0 // num in chache no need to compute
 * 		retuurn len+chache[key]
 * 	e. else if(key < chache_size && chache[key] == 0 // num in not chache compute and update chache
 * 		chache[key] = 1 + HSS_CYCLE_LEN(num >> 1 + num +1) // 3n+1
 * 		return len + chache[key]
 * 	f. else
 * 		return 1 + len + HSS_CYCLE_LEN(num >> 1 + num +1) // 3n+1
 *
 *
 *
 * Build:
 * gcc hss.c -o hailstone.exe
 * Run:
 * $./hailstone
 * $ a b
 * ...
 */


#include <stdio.h>
#include <string.h>
#define ultype unsigned long 
#define ltype long

#define CHAR_BIT 8

ultype  Max(ultype x, ultype y) {
	return x ^ ((x ^ y) & -(x < y));
}

ultype  Min(ultype x, ultype y) {
	return y ^ ((x ^ y) & -(x < y));
}

ltype Abs(ltype v) {
	ltype mask = v >> ((sizeof(ltype) * CHAR_BIT) - 1);
	return (v + mask) ^ mask;
}

static unsigned long Mod37BitPosition[] = { 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 };

#define schache_size  0x400UL
static short precomputed_chache[schache_size] = {1,  8,  6,  17,  20,  15,  10,  18,  13,  21,  8,  16,  24,  112,\
19,  107,  27,  14,  22,  35,  110,  30,  17,  105,  25,  25,  12,  113,  33,  33,  20,  108,  28,  28,  15,  103,\
116,  15,  23,  36,  23,  111,  10,  31,  31,  93,  18,  106,  119,  26,  26,  88,  39,  101,  114,  70,  13,  34,\
21,  34,  96,  47,  109,  47,  122,  29,  29,  42,  91,  42,  16,  104,  117,  117,  24,  16,  37,  86,  37,  55,\
99,  24,  112,  68,  50,  125,  32,  81,  32,  32,  19,  94,  45,  45,  107,  45,  120,  120,  27,  120,  19,  40,\
27,  89,  40,  40,  14,  102,  27,  53,  115,  71,  53,  14,  35,  128,  84,  128,  35,  53,  22,  97,  22,  48,\
48,  66,  110,  48,  123,  123,  30,  79,  123,  22,  30,  43,  30,  92,  17,  43,  43,  61,  105,  43,  30,  118,\
118,  56,  74,  118,  17,  43,  38,  38,  25,  87,  131,  38,  38,  56,  25,  100,  25,  144,  51,  25,  113,  69,\
113,  51,  12,  126,  126,  126,  33,  82,  126,  33,  33,  51,  46,  46,  95,  46,  20,  46,  20,  46,  64,  59,\
108,  46,  33,  121,  121,  121,  59,  77,  28,  121,  20,  20,  28,  41,  41,  134,  90,  134,  134,  41,  41,\
33,  59,  54,  103,  41,  28,  28,  116,  54,  28,  54,  72,  98,  116,  54,  15,  41,  129,  129,  36,  129,  36,\
85,  23,  129,  36,  28,  36,  54,  49,  23,  98,  142,  49,  142,  49,  98,  23,  49,  111,  67,  62,  36,  49,\
62,  36,  124,  124,  62,  124,  124,  31,  80,  31,  124,  31,  23,  23,  49,  44,  137,  44,  31,  93,  44,  137,\
31,  44,  88,  44,  44,  18,  62,  57,  31,  106,  44,  31,  31,  119,  31,  57,  119,  119,  57,  75,  75,  26,\
119,  57,  70,  18,  44,  132,  39,  39,  70,  132,  132,  88,  132,  26,  132,  39,  39,  31,  31,  57,  132,  52,\
26,  101,  39,  145,  101,  26,  145,  52,  52,  114,  26,  52,  145,  70,  96,  65,  114,  52,  65,  65,  39,  127,\
39,  127,  127,  34,  127,  127,  65,  83,  171,  34,  127,  34,  65,  26,  26,  34,  52,  47,  47,  21,  47,  34,\
140,  96,  47,  140,  21,  47,  96,  91,  47,  47,  140,  21,  65,  109,  60,  34,  153,  47,  60,  34,  34,  122,\
153,  34,  60,  122,  122,  122,  60,  29,  78,  78,  104,  122,  73,  60,  21,  21,  73,  47,  135,  42,  135,  42,\
42,  29,  135,  135,  42,  91,  135,  29,  135,  42,  86,  42,  42,  42,  34,  60,  60,  16,  55,  29,  148,  104,\
42,  148,  29,  29,  179,  148,  29,  55,  148,  117,  29,  117,  55,  148,  47,  73,  99,  68,  117,  55,  117,\
68,  55,  16,  42,  130,  130,  37,  130,  130,  68,  130,  117,  130,  37,  86,  130,  174,  86,  130,  37,  37,\
37,  37,  29,  29,  29,  55,  130,  50,  50,  24,  143,  50,  37,  99,  143,  99,  50,  24,  143,  24,  37,  50,\
99,  94,  24,  50,  50,  143,  42,  68,  94,  112,  63,  112,  37,  156,  63,  50,  63,  37,  37,  125,  37,  156,\
125,  125,  63,  125,  125,  32,  125,  63,  94,  81,  169,  81,  32,  125,  76,  76,  63,  24,  169,  24,  24,  32,\
50,  138,  138,  45,  138,  45,  45,  32,  76,  138,  32,  94,  45,  94,  138,  19,  32,  138,  94,  45,  89,  45,\
45,  45,  138,  37,  37,  63,  63,  19,  58,  107,  32,  151,  58,  45,  58,  151,  32,  32,  58,  182,  151,  120,\
32,  58,  58,  120,  120,  32,  58,  58,  89,  151,  76,  76,  50,  102,  120,  120,  71,  58,  58,  19,  71,  58,\
71,  45,  164,  133,  133,  40,  133,  133,  133,  40,  71,  133,  133,  27,  133,  40,  71,  89,  133,  177,  27,\
133,  89,  40,  84,  40,  177,  40,  32,  40,  32,  32,  84,  58,  133,  53,  53,  27,  146,  146,  53,  102,  40,\
102,  146,  27,  102,  53,  177,  146,  102,  27,  53,  53,  146,  102,  53,  27,  53,  53,  53,  115,  146,  45,\
27,  71,  97,  115,  66,  115,  159,  40,  115,  53,  66,  53,  66,  14,  40,  40,  115,  128,  40,  159,  128,\
128,  97,  66,  66,  128,  115,  35,  128,  35,  66,  97,  128,  84,  172,  84,  35,  128,  35,  79,  128,  35,\
66,  27,  27,  35,  27,  27,  79,  53,  128,  141,  48,  48,  53,  141,  141,  48,  141,  35,  35,  97,  141,  35,\
141,  48,  172,  97,  141,  22,  97,  35,  141,  48,  97,  48,  92,  22,  48,  48,  48,  48,  141,  40,  22,  66,\
92,  66,  141,  61,  154,  110,  35,  110,  154,  61,  61,  48,  61,  154,  35,  35,  110,  61,  35,  123,  154, \
123,  35,  123,  61,  61,  154,  123,  61,  35,  123,  61,  61,  92,  123,  79,  167,  79,  79,  30,  105,  123,\
74,  123,  74,  61,  61,  22,  167,  74,  22,  22,  74,  48,  48,  30,  136,  136,  74,  43,  136,  136,  43,  43,\
105,  74,  74,  136,  136,  30,  136,  92,  43,  74,  43,  136,  74,  180,  30,  136,  43,  92,  136,  43,  87,  43,\
43,  43,  43,  35,  136,  35,  180,  35,  61,  61,  61,  136,  149,  56,  149,  30,  30,  105,  149,  56,  56,  43,\
56,  105,  149,  30,  105,  105,  56,  30,  180,  149,  149,  118,  30,  56,  43,  56,  149,  105,  118,  30,  149,\
56,  56,  56,  87,  118,  149,  74,  48,  30,  48,  100,  100,  118,  69,  118,  69,  162,  43,  56,  118,  56,  69,\
17,  56,  69,  162,  43,  162,  43,  131,  131,  69,  43,  131,  131,  162,  131,  131,  38,  69,  69,  131,  131,\
118,  38,  131,  38,  69,  69,  38,  87,  131,  87,  175,  25,  87,  38,  87,  131,  38,  82,  38,  38,  175,  69,\
69,  30,  131,  38,  30,  38,  30,  82,  175,  56,  131,  144,  51,  51,  51,  56,  144,  25,  144,  51,  51,  100,\
38,  38,  82,  144,  175,  38,  100,  51,  82,  175,  82,  144,  100,  25,  25,  51,  38,  144,  144,  100,  51,\
51,  95,  25,  51,  51,  51,  51,  51,  51,  144,  113,  43,  25,  43,  69,  95,  69,  113,  64,  157,  157,  157,\
38,  64,  113,  157,  51,  64,  64,  157,  64,  157}; 

/* _NO_CHACHE_ can be defined to run the algorithm without chaching
 * (Note: _NO_CHACHE_ dynamic chache of <schache_size> odd elements)
 * Algorith uses two types of chache to hash intermidiate results
 * A. Precomputed chache of <schache_size> odd elements < 2*<schache_size>
 * B. Dynamic on the fly chache of dchache_size to direct hash intermidiate
 *    odd elements, even elments are not chached, switch on the flag
 *
 *    With _NO_CHACHE_ / without _NO_CHACHE_ will change the time compleity
 *    by 10% for a = 1 b= 1000000
 */

#ifndef _NO_CHACHE_
#define dchache_size 0x0007FFFFUL   
#else
#define dchache_size 0x400UL 
#endif

static short dynamic_chache[dchache_size+1];
static short* chache[2]; 

#define stack_len 0x400
short running_stack_len[stack_len];
ultype running_stack_num[stack_len];

#define count_trailing_zeros(v) Mod37BitPosition[(-(v) & (v)) % 37]

/* Get hash Key
 *
 */
#define get_key(index, num) \
	(index == 0 ? ((num) >> 1) : (((num) >> 1)-schache_size))	

/* Update hash
*/ 
void update_hash(short hss_len) {
	short stack_ptr = 0;
	unsigned long key = 0;
	while((running_stack_len[stack_ptr] != -1)) {
		key = get_key(1, running_stack_num[stack_ptr]);
		if(key <= dchache_size) {
			chache[1][key] = hss_len-running_stack_len[stack_ptr];
		}
		stack_ptr++;
	}
}

/* Procedure to compute HSS cycle length for any unsigned number
*/
short Cal_hss_length(ultype num) {
	short hss_len = 0;
	unsigned short index = 0;
	unsigned long key = 0;
	short stack_ptr = -1;
	while(stack_ptr < stack_len-1) {
		/* If it is an Even number hss_len > 0
		 * Compute hss length till number becomes odd
		 */
		unsigned short trailing_zeros = count_trailing_zeros(num);
		num >>= trailing_zeros; 
		hss_len += trailing_zeros; 

		/* Select chache 0/1 
		 * and hash key
		 * */
		index = ((num & 0xFFFFF800UL) >> count_trailing_zeros(num & 0xFFFFF800UL))  & 0x01UL;
		key = get_key(index, num);


		/*   -----  It is an odd number -----
		 *	 a. check in chache for O(1) retrival
		 *	 b. Compute the hss length for this odd number
		 *	 and Hash the odd number > 2*<schache_size> in D-chache
		 **/
		if( (key <= dchache_size) && chache[index][key] != 0) {
			hss_len += chache[index][key];
			break;
		} 
		stack_ptr++;
		running_stack_num[stack_ptr] = num;
		running_stack_len[stack_ptr] = hss_len;
		hss_len++;
		num = (num << 1) + num + 1;
	}
	/* update Hash Table 
	 * */
	stack_ptr++;
	running_stack_len[stack_ptr] = -1;
	update_hash(hss_len);
	return hss_len;
}

/* Compute the Max HSS cycle length starting from A to A+len
*/

short Max_hss_length(ultype num,  long len) {
	if (num == 0) return 0;
	short max_sofar = 0;

	while (len-- >= 0) {
		max_sofar = Max(max_sofar, Cal_hss_length(num++));
	}

	return max_sofar;
}

/* main
 * this will wait for two space separated inputs a b till EOF 
 * */

int main() {
	ultype start=0, end=0;
	short max_len=0;
	memset(dynamic_chache, 0 , dchache_size+1);
	chache[0] = precomputed_chache;
	chache[1] = dynamic_chache;
	while (scanf("%lu %lu", &start, &end ) != EOF) {
		max_len = Max_hss_length(Min(start, end), Abs(start-end));
		printf("%lu %lu %hi\n", start, end, max_len);
	}
	return 0;
}
